package com.ftg.learn.chapter13;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.function.ToDoubleFunction;
import java.util.stream.IntStream;
import java.util.stream.Stream;

/**
 * 学习3
 *
 * @author kangjx
 * @version 1.0
 * @date 2023/2/16 上午11:15
 */
public class LearnStream03 {

    public static void main(String[] args) {
        Employeer[] emps = new Employeer[8];
        //聚合统计功能
        // 列出我们公司员工资大15000 和小于15000

        emps[0] = new Employeer("张三", new BigDecimal("10000"), "男", 1);
        emps[1] = new Employeer("李四", new BigDecimal("12000"), "男", 1);
        emps[2] = new Employeer("王五", new BigDecimal("18000"), "男", 1);
        emps[3] = new Employeer("李二狗", new BigDecimal("18000"), "男", 1);
        emps[4] = new Employeer("王春花", new BigDecimal("18000"), "女", 1);
        emps[5] = new Employeer("史小丽", new BigDecimal("18000"), "女", 1);
        emps[6] = new Employeer("高启强", new BigDecimal("18000"), "男", 1);
        emps[7] = new Employeer("王二狗", new BigDecimal("18000"), "男", 1);
        //目标是把emps 流里面的元素映射成指定的新的 Double流

        Arrays.stream(emps).map(x->x.getSal()).forEach(System.out::println);
        double totalSal = Arrays.stream(emps).mapToDouble((x)->x.getSal().doubleValue()).reduce(1000000,Double::sum);
        System.out.println(totalSal);

    }
}
